var zTree;
var setting = {
		check : {
			enable : true
		},
		data : {
			simpleData : {
					idKey : "id",
					pIdKey : "pId",
					enable : true,
					rootPId : 0
			}
		}
};
$(function() {
	zTree = $.fn.zTree.init($("#roleMenuTree"), setting, treeData);
});

function closeLayer() {
	parent.layer.closeAll('iframe');
}

function save() {
	var checkedNode = zTree.getCheckedNodes(true);
	var ids = [];
	for (var i = 0; i < checkedNode.length; i++) {
		ids[i] = checkedNode[i].id;
	}
	var ids = JSON.stringify(ids);

	$.ajax({
			url : RS.webPath + "/admin/rsRoleMenu/edit",
			type : 'post',
			data : 'menuIds=' + ids + "&role_id=" + role_id,
			dataType : 'json',
			success : function(data) {
				if (data.status >= 1) {
					parent.layer.alert('提交成功', function(index) {
						parent.layer.closeAll('iframe');
						parent.layer.close(index);
					});
				} else {
					parent.layer.alert('提交失败');
				}
			}
	});
}
